package controller;

import core.BaseServlet;
import service.BusinessService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "BusinessServlet", urlPatterns = "/business")
public class BusinessServlet extends BaseServlet {

    private BusinessService businessService = new BusinessService();

    /**
     * 营业管理页面
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void businessManagePage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getRequestDispatcher("/WEB-INF/pages/operationManage/businessManage/businessManage.jsp").forward(request,response);
    }

    /**
     * 获取柱状图的日期和营业额数据
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void findOrderMoneyByDay(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       businessService.findOrderMoneyByDay(request, response);
    }

    /**
     * 获取今日的订单数量
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void findOrderCountByDay(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       businessService.findOrderCountByDay(request, response);
    }

    /**
     * 获取今日最热食品
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void findPopularFood(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       businessService.findPopularFood(request, response);
    }

    /**
     * 获取累计销售热门的食品
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void findAllPopularFood(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       businessService.findAllPopularFood(request, response);
    }
    /**
     * 获取4个累计销售热门的食品
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void find4PopularFood(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       businessService.find4PopularFood(request, response);
    }
}
